
from datetime import datetime
from typing import Optional
from sqlmodel import Field, SQLModel
from core.commons import Disabled

class UserBase(SQLModel):
    username:str = Field(default=...,max_length=30,unique=True,index=True,title="用户名【车牌号】")
    license_plate:str = Field(default=...,max_length=20,unique=True,index=True,title="车牌号")
    disabled:Disabled = Field(default=Disabled.OFF,title="是否禁用")
    create_at: datetime = Field(default=datetime.now(),title="创建时间")
    update_at: Optional[datetime] = Field(default=None,title="创建时间")

class User(UserBase,table=True):
    __tablename__ = "users"
    id: Optional[int] = Field(default=None, primary_key=True,title="自增主键id")
    hashed_password: str = Field(default=...,max_length=200,title="密码")